package com.demo.mq;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

public class ScheduledMessageProducer {

     public static void main(String[] args) throws Exception {
         DefaultMQProducer producer = new DefaultMQProducer("shanchong_test");
         producer.setNamesrvAddr("10.0.0.154:9876");
         producer.start();
         int totalMessagesToSend = 100;
         for (int i = 0; i < totalMessagesToSend; i++) {
             Message message = new Message("TestTopic", ("Hello scheduled message " + i).getBytes());
             // 1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
             message.setDelayTimeLevel(5);
             producer.send(message);
         }
         producer.shutdown();
     }
}
